<?php
/**
 * Created by PhpStorm.
 * User: lijiao
 * Date: 15/6/27
 * Time: 下午3:45
 */

namespace app\controllers;

use app\models\Order;
use Yii;
use yii\caching\DbDependency;
use yii\caching\ExpressionDependency;
use yii\caching\FileDependency;
use yii\filters\AccessControl;
use yii\web\Controller;
use app\models\Customer;

class HelloController extends Controller
{
    public $layout = 'main';

    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['@'],
                    ],

                ],
            ],
        ];
    }

    public function actionIndex()
    {
        $this->layout = "main";

        $arr = array(1,2);
        $total = 0;
        for($i = 0;$i <100;$i++)
        {
            $a = $arr[array_rand($arr)];
            $b = $arr[array_rand($arr)];
            if($a == $b && $a == 1)
            {
                $total = $total+3;
            }elseif($a == $b && $a == 2){
                $total = $total+1;
            }else{
                $total = $total-1;
            }
        }
        echo $total."<br>";
        return $this->render('index');
    }

    public function actionTest()
    {
        $this->layout = 'common.php';
    }

}